﻿//禁止文本框外的文本选取
document.onselectstart = function () {
    var obj = event.srcElement;
    if (obj.type == 'text') {
        return true;
    }
    else {
        return false;
    }
}

//禁止显示右键菜单
document.oncontextmenu = function () {
    var obj = event.srcElement;
    if (obj.type == 'text') {
        return true;
    }
    else {
        return false;
    }
}

//清空TextBox
//使用js,好处是不用刷新页面：   
function ClearTextBox() {
    var obj = window.document.forms[0];
    for (i = 0; i < obj.elements.length; i++) {
        var elem = obj.elements[i];
        if (elem) {
            if (elem.type == "text") {
                elem.value = "";
            }
        }
    }
}
//最后一种用Jquery   
function ClearText() {
    $("input").each(function () {
        $(this).val('');
    });

}


//刷新当前页面
function Refresh() {
    document.location.reload();
   
}

//自定义AJAX数据抛回 (使用需要注册)
//__doPostBack(id, eventArgument)来和控件交互。doPostBack的用法是，id: 服务器控件的ClientID，eventArgument: 传回服务器的参数。
//这个参数在服务器端通过IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)来读取.
function PostBackByObject(ControlID) {
    var o = window.event.srcElement;
    if (o.tagName == "INPUT" && o.type == "checkbox") {
        __doPostBack(ControlID, "");
    }
}

//Div动态样式
//x:Div外围Table上下线条(24+4)|y:Div外围Table左右线条(3+3)|s:页面边距|t:DivTop高度(自定义)|r:DivRight宽度(自定义)|b:DivBottom高度(自定义)|l:DivLeft宽度(自定义)|w:页面可操作宽度|h:页面可操作高度
function DivScrollStyle(IsPageButton, IsGridPager) {

    var x = 28; var y = 6; var s = 8;
    var t = 0; var r = 0; var b = 0; var l = 0;
    var w = document.documentElement.clientWidth;
    var h = document.documentElement.clientHeight;
    var q = h - s;
    var m = w - s;
    var n = h - s;
    try {
        t = document.getElementById("DivTop").style.height;
        t = parseInt(t);
        n = n - t - x;
    }
    catch (e)
    { }
    try {
        b = document.getElementById("DivBottom").style.height;
        b = parseInt(b);
        n = n - b - x;
        q = q - b - x;
    }
    catch (e)
    { }
    try {
        l = document.getElementById("DivLeft").style.width;
        l = parseInt(l);
        m = m - l - y;
    }
    catch (e)
    { }
    try {
        r = document.getElementById("DivRight").style.width;
        r = parseInt(r);
        m = m - r - y;
    }
    catch (e)
    { }

    if (IsPageButton == "1") {
        n = n - x;
        q = q - x;
    }

    try {
        document.getElementById("DivLeft").style.height = q - x + "px";
    }
    catch (e)
    { }
    try {
        document.getElementById("DivRight").style.height = n - x + "px";
    }
    catch (e)
    { }
    try {
        if (IsGridPager == "1") {
            n = n - 22;
        }
        document.getElementById("DivBody").style.width = m - y + "px";
        document.getElementById("DivBody").style.height = n - x + "px";
        document.getElementById("TabContainer1").style.height = n - x + "px";
    }
    catch (e)
    { }
    try {
        document.getElementById("DivTop").style.width = m - y + "px";
    }
    catch (e)
    { }
    try {
        document.getElementById("DivBottom").style.width = w - s - y + "px";
    }
    catch (e)
    { }
}